
import { timeFn } from '@/utils/index'
export default {
  data() {
    return {
      ruleForm: {
        workOrderNo: null,
        systemName: null,
        eventStatus: null,
        eventLevel: null,
        eventSource: null,
        faultType: null,
        area: null,
        declarer: null,
        receiver: null,
        faultPhenomenon: null
      },
      dialogVisible: false
    }
  },
  computed: {
    searchOptions() {
      return [
        {
          value: 'cableCode',
          key: 'cableCode',
          label: '电文代码',
          type: 'input',
          placeholder: '请输入电文代码'
        },
        {
          value: 'receiveTime',
          key: 'receiveTime',
          dateType: 'datetimerange',
          label: '接收时间',
          type: 'date',
          style: 'width: 220px',
          valueFormat: 'yyyy-MM-dd HH:mm:ss',
          placeholder: '请选择接收时间'
        }
      ]
    },
    tablecolumn() {
       return [
          {
            width: '55',
            fixed: 'left',
            type: 'selection',
            reserveSelection: true,
            align: 'center'
          },
          {
            width: '120',
            label: '订单号',
            align: 'center',
            prop: 'orderNumPf',
            render: (h, params) => {
              return h('a', {
               style: {
                 color: '#1890ff',
                 cursor: 'pointer'
               },
               on: {
                click: () => {
                  this.showDetail(params.row)
                }
              }
              }, params.row.orderNumPf)
            }
          },
          {
            minWidth: '120',
            label: '订单状态',
            prop: 'orderStatusPf'
          },
          {
            minWidth: '120',
            label: '订货凭据',
            prop: 'orderCertNo',
            showOverflowTooltip: true
          },
          {
            label: '订单性质代码',
            minWidth: '120',
            prop: 'orderTypeCode',
            showOverflowTooltip: true
          },
          {
            label: '内外销标志',
            minWidth: '120',
            prop: 'expFlag',
            showOverflowTooltip: true
          },
          {
            label: '订货期别',
            minWidth: '120',
            prop: 'orderPeriodPf',
            showOverflowTooltip: true
          },
          {
            label: '产品大类代码',
            minWidth: '120',
            prop: 'prodClassCode',
            showOverflowTooltip: true
          },
          {
            label: '公司别',
            minWidth: '120',
            prop: 'companyCodePf',
            showOverflowTooltip: true
          },
          {
            label: '贸易方式',
            minWidth: '120',
            prop: 'tradeMode',
            showOverflowTooltip: true
          },
          {
            label: '结算方式代码',
            minWidth: '120',
            prop: 'settleMode',
            showOverflowTooltip: true
          },
          {
            label: '履约地点代码',
            minWidth: '120',
            prop: 'signSitePf',
            showOverflowTooltip: true
          },
          {
            label: '计价方式',
            minWidth: '120',
            prop: 'priceFormulaMode',
            showOverflowTooltip: true
          },
          {
            label: '合约录入日期',
            minWidth: '180',
            prop: 'contInDate',
            showOverflowTooltip: true
          },
          {
            label: '合约录入人',
            minWidth: '120',
            prop: 'contInPerson',
            showOverflowTooltip: true
          },
          {
            label: '订单变更中标志',
            minWidth: '120',
            prop: 'orderModiMark',
            showOverflowTooltip: true
          },
          {
            label: '订货用户代码',
            minWidth: '120',
            prop: 'orderUserCodePf',
            showOverflowTooltip: true
          },
          {
            label: '订货用户中文名称',
            minWidth: '120',
            prop: 'orderUserCnamePf',
            showOverflowTooltip: true
          },
          {
            label: '订货用户地址码',
            minWidth: '120',
            prop: 'orderUserAddrNum',
            showOverflowTooltip: true
          },
          {
            label: '订货用户地址',
            minWidth: '120',
            prop: 'orderUserAddrNamePf',
            showOverflowTooltip: true
          },
          {
            label: '合约子项数量',
            minWidth: '120',
            prop: 'contOrderNum',
            showOverflowTooltip: true
          },
          {
            label: '合约总重量',
            minWidth: '120',
            prop: 'contTotWt',
            showOverflowTooltip: true
          },
          {
            label: '合约总金额',
            minWidth: '120',
            prop: 'contTotAmt',
            showOverflowTooltip: true
          },
          {
            label: '税率',
            minWidth: '120',
            prop: 'taxRatePf',
            showOverflowTooltip: true
          },
          {
            label: '操作',
            fixed: 'right',
            width: 120,
            render: (h, params) => {
              return h('div', [
                h('el-button', {
                  props: {
                    type: 'text',
                    size: 'small',
                    loading: false
                  },
                  style: {
                    marginRight: '5px'
                  },
                  on: {
                    click: () => {
                      this.modifyTop(params.row)
                    }
                  }
                }, '修改'),
                h('el-button', {
                  props: {
                    type: 'text',
                    size: 'small',
                    loading: false
                  },
                  style: {
                    marginRight: '5px'
                  },
                  on: {
                    click: () => {
                      this.deleteTop(params.row)
                    }
                  }
                }, '删除')
              ])
            }
          }
        ]
    },
    childTablecolumn() {
      return [
        {
          width: '55',
          fixed: 'left',
          type: 'selection',
          reserveSelection: true,
          align: 'center'
        },
        {
          label: '合同号',
          prop: 'orderNo',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '合同子项序号',
          prop: 'orderLastSeqNo',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '销售业务员工号',
          prop: 'saleId',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '记录创建时间',
          prop: 'recCreateTime',
          minWidth: '180',
          showOverflowTooltip: true
        },
        {
          label: '销售订单子项状态',
          prop: 'orderItemStatusCode',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '订单子项变更中标记',
          prop: 'orderItemModiMark',
          minWidth: '140',
          showOverflowTooltip: true
        },
        {
          label: '变更原因',
          prop: 'modiCause',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '变更日期',
          prop: 'modiDate',
          minWidth: '180',
          showOverflowTooltip: true
        },
        {
          label: '合同变更操作人',
          prop: 'modiOperPerson',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '变更性质',
          prop: 'modiType',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '最终用户代码',
          prop: 'finUserNum',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '最终用户名称',
          prop: 'finUserName',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '最终用户的行业代码',
          prop: 'finUserTrade',
          minWidth: '160',
          showOverflowTooltip: true
        },
        {
          label: '收货用户代码',
          prop: 'consignNum',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '收货用户名称',
          prop: 'consignNamePf',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '收货用户地址码',
          prop: 'cnsgAddressNum',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '收货用户地址',
          prop: 'cnsgAddressPf',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '产品规范码',
          prop: 'psr',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '冶金规范码',
          prop: 'msc',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '产品名称',
          prop: 'productDscr',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '牌号',
          prop: 'shopSignPf',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '产品标准',
          prop: 'steelStd',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '性能是否要求标志',
          prop: 'capabYnFlag',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '质保书类型',
          prop: 'qcType',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '质保书份数',
          prop: 'certiNum',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '包装代码',
          prop: 'packingCode',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '订单优先级',
          prop: 'orderPriority',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '订货厚',
          prop: 'orderThick',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '订货宽',
          prop: 'orderWidthPf',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '订货长度下限',
          prop: 'orderLenLow',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '订货长度上限',
          prop: 'orderLenUp',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '计重方式',
          prop: 'weightMethod',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '订货计量单位',
          prop: 'orderUnit',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '订货件数',
          prop: 'orderPiece',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '内径',
          prop: 'coilInsideDimPf',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '订单备妥日期',
          prop: 'orderReadyDate',
          minWidth: '180',
          showOverflowTooltip: true
        },
        {
          label: '销售单价',
          prop: 'saleUnitPrice',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '协议价格单号',
          prop: 'agreemtCode',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '协议价格',
          prop: 'agreePrice',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '运输类型',
          prop: 'transType',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '运输方式代码',
          prop: 'trnpModeCodePf',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '水压',
          prop: 'hydraulicPressure',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '探伤',
          prop: 'crackDetection',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '低温',
          prop: 'lowTemperature',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '联系人',
          prop: 'contactName',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '联系电话',
          prop: 'telNum',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '装车方式',
          prop: 'carModel',
          minWidth: '120',
          showOverflowTooltip: true
        },
        {
          label: '操作',
          fixed: 'right',
          width: 120,
          render: (h, params) => {
            return h('div', [
              h('el-button', {
                props: {
                  type: 'text',
                  size: 'small',
                  loading: false
                },
                style: {
                  marginRight: '5px'
                },
                on: {
                  click: () => {
                    this.modifyChild(params.row)
                  }
                }
              }, '修改'),
              h('el-button', {
                props: {
                  type: 'text',
                  size: 'small',
                  loading: false
                },
                style: {
                  marginRight: '5px'
                },
                on: {
                  click: () => {
                    this.deleteChild(params.row)
                  }
                }
              }, '删除')
            ])
          }
        }
      ]
    }
  },
  methods: {
    openQurey() {
      this.dialogVisible = true
      this.dragDialog && this.dragDialog.rest()
    },
    // 获取值集对应lable
    getCodeLabel(key, code) {
      if (!code) {
        return code || ''
      }
      if (this.codesList[key]) {
        return this.codesList[key][code] || ''
      }
    },
    // 计算派发时间
    countAssignTime(h, params) {
      const rs = [h('p', params.row.declareTime)]
      if (!['15', '4', '17', '19'].includes(params.row.eventStatus)) {
        let preword = '已用时'
        let endtime = ''
        if (params.row.completeTime || params.row.completeTime2) {
          endtime = params.row.completeTime || params.row.completeTime2
          preword = '总用时'
        }
        let time = ''
        if (endtime && params.row.declareTime > endtime) {
          time = timeFn(params.row.declareTime, '')
        } else {
        time = timeFn(params.row.declareTime, endtime)
        }
        rs.push(h('p', preword + `${time}`))
      }
      return h('div', {
        style: {
          color: '#e6a700'
        }
       }, rs)
    }
  }
}
